#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <stdlib.h>
#include <math.h>
#include <time.h>


void checkAdventurer(int p, struct gameState *post, int handPos)
{
  struct gameState pre;
  memcpy (&pre, post, sizeof(struct gameState));
  int r;
  int i;
  int j;
  int k;
  int x;
  int index;
  int currentPlayer = whoseTurn(post);
  int nextPlayer = currentPlayer + 1;
  int tributeRevealedCards[2] = {-1, -1};
  int temphand[MAX_HAND];// moved above the if statement
  int drawntreasure=0;
  int cardDrawn;
  int z;// this is the counter for the temp hand
  if (nextPlayer > (post->numPlayers - 1)){
    nextPlayer = 0;
  }

  printf ("Adventurer PRE: HC %d DeC %d DiC %d\n",
          pre.handCount[p], pre.deckCount[p], pre.discardCount[p]);
  
  r = zzzadventurercardplay(drawntreasure, currentPlayer, cardDrawn, temphand, z, post);

  printf ("Adventurer POST: HC %d DeC %d DiC %d\n",
            post->handCount[p], post->deckCount[p], post->discardCount[p]);
}

int main () {

  int i, n, r, p, deckCount, discardCount, handCount;
  int numTests = 10000;

  int k[10] = {adventurer, council_room, feast, gardens, mine,
         remodel, smithy, village, baron, great_hall};

  struct gameState G;

  printf ("Testing Adventurer\n");

  srand(time(NULL));

  printf ("RANDOM TESTS: MAX_DECK, MAX_HAND\n");
  for(n = 0; n < numTests; ++n){
    for (p = 0; p < 2; p++) {
      int handP, handQ;
      memset(&G, 23, sizeof(struct gameState)); 
      r = initializeGame(2, k, 1, &G);
      G.deckCount[p] = rand() % MAX_DECK + 1;
      memset(G.deck[p], 0, sizeof(int) * deckCount);
      G.discardCount[p] = rand() % MAX_DECK + 1;
      memset(G.discard[p], 0, sizeof(int) * discardCount);
      G.handCount[p] = handQ = rand() % MAX_HAND + 1;
      memset(G.hand[p], 0, sizeof(int) * handCount);
      handP = rand() % handQ;
      checkAdventurer(p, &G, handP);
      printf("%d\n", n);
    }
  }

  printf ("ALL TESTS OK\n");

  exit(0);
}


